﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using KeaoBase;

namespace KeaoMDS.Report
{
    public partial class PiZhongChaoCha : BaseForm
    {
        public PiZhongChaoCha()
        {
            InitializeComponent();
        }

        private void PiZhongChaoCha_Load(object sender, EventArgs e)
        {
            grid_chaocha.AutoGenerateColumns = false;
            dateTimePicker1.Value = DateTime.Today;
            dateTimePicker2.Value = dateTimePicker1.Value.AddHours(23).AddMinutes(59).AddSeconds(59);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            BindInfo();
        }

        private void BindInfo()
        {
           string createCondition = KeaoUtils._DB.CreateAndCondition("chengzhongshijian", DataValueCommonType.日期时间, dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss"), dateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:ss"), SearchConditionType.between);
           if (!string.IsNullOrEmpty(txt_chepaihao.Text))
           {
               createCondition += KeaoUtils._DB.CreateAndCondition("chepaihao", DataValueCommonType.字符串, txt_chepaihao.Text, "", SearchConditionType.like);
           }
           Dictionary<string, string> orderBy = new Dictionary<string, string>();
           orderBy.Add("chengzhongshijian", "desc");
           DataTable Dt = KeaoUtils._DB.GetDataTableByCondition("tbl_pizhongyichang", createCondition,orderBy);
           grid_chaocha.DataSource = Dt;
            
        }

        private void grid_chaocha_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
        {
            e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
        }
    }
}
